package com.androinject.core.aware;

import com.androinject.core.definitions.ComponentDefinition;
import com.androinject.core.definitions.ManagedComponentDefinition;
import com.androinject.core.factory.AbstractComponentProcessor;

public class ComponentInitializationAwareProcessor extends AbstractComponentProcessor {

	@Override
	public void afterComponentInjection(Object component, ComponentDefinition definition) {
		super.afterComponentInjection(component, definition);
		this.handleComponent(component);
	}
	
	
	@Override
	public void afterManagedComponentInjection(Object component, ManagedComponentDefinition definition) {
		super.afterManagedComponentInjection(component, definition);
		this.handleComponent(component);
	}
	
	
	protected void handleComponent(Object component) {
		if (component instanceof ComponentInitializationAware) {
			((ComponentInitializationAware) component).afterInjectionFinished();
		}
	}
}
